package com.classichu.jetpacksimple.data.remote;


import com.classichu.jetpacksimple.data.remote.api.DoubanApi;
import com.classichu.jetpacksimple.data.remote.api.MeiziApi;
import com.classichu.jetpacksimple.data.remote.api.ZhihuApi;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

public class ApiManager {
    private static final String BASE_URL_ZHIHU = "https://news-at.zhihu.com/";
    private static final String BASE_URL_MEIZI = "http://gank.io/";
    private static final String BASE_URL_DOUBAN= "https://api.douban.com/v2/";

    private ApiManager() {

    }

    public static ApiManager getInstance() {
        return Inner.sInstance;
    }

    private static class Inner {
        private static final ApiManager sInstance = new ApiManager();
    }

    public ZhihuApi getZhihuApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL_ZHIHU)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
//                .client(OkHttpManager.getInstance().getOkHttpClient())
                .build();
        return retrofit.create(ZhihuApi.class);
    }

    public MeiziApi getMeiziApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL_MEIZI)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
//                .client(OkHttpManager.getInstance().getOkHttpClient())
                .build();
        return retrofit.create(MeiziApi.class);
    }

    public DoubanApi getDoubanApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL_DOUBAN)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
//                .client(OkHttpManager.getInstance().getOkHttpClient())
                .build();
        return retrofit.create(DoubanApi.class);
    }
}
